<?php
	if(!isset($id))
	{
		$set_nama 		= set_value("nama");
		$set_notelp 	= set_value("no_telp");
		$set_email 		= set_value("email");
		$set_isi 		= set_value("isi");
		$set_uptsa		= set_value("no_uptsa");
	}
	else
	{
		$set_nama		= (set_value("nama") == "")?($list["NAMA"]) : (set_value("nama"));
		$set_notelp		= (set_value("no_telp") == "")?($list["NO_TELEPON"]) : (set_value("no_telp"));
		$set_email		= (set_value("email") == "")?($list["EMAIL"]) : (set_value("email"));
		$set_isi		= (set_value("email") == "")?($list["ISI"]) : (set_value("isi"));
		$set_media		= (set_value("media") == "")?($list["MEDIA"]) : (set_value("media"));
		$set_tanggal	= (set_value("tanggal") == "")?($list["TANGGAL"]) : (set_value("tanggal"));
		$set_ijin		= (set_value("ijin") == "")?($list["KD_IJIN"]) : (set_value("ijin"));
		$set_uptsa		= (set_value("no_uptsa") == "")?($list["NO_UPTSA"]) : (set_value("no_uptsa"));
	}

?>
<style>
label{
	text-align:right;
}
</style>
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>
					<span>Form Pengaduan & Saran</span>
				</h4>
			</div>
			<?php echo form_open($post_action);?>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-lg-3 control-label" for="input">Nama</label>
					<div class="col-lg-6">
						<input type="text" class="form-control elastic" id="nama" name="nama" value="<?=$set_nama?>">						
					</div>
					<font color="red"><?php echo form_error("nama"); ?></font>
				</div>
				<br>
				<br>
				<div class="form-group">
					<label class="col-lg-3 control-label" for="input">No. Telepon</label>
					<div class="col-lg-6">
						<input type="text" class="form-control elastic" id="no_telp" name="no_telp" value="<?=$set_notelp?>">						
					</div>
					<font color="red"><?php echo form_error("no_telp"); ?></font>
				</div>
				<br>
				<br>
				<div class="form-group">
					<label class="col-lg-3 control-label" for="input">Email</label>
					<div class="col-lg-6">
						<input type="text" class="form-control elastic" id="email" name="email" value="<?=$set_email?>">						
					</div>
					<font color="red"><?php echo form_error("email"); ?></font>
				</div>
				<br>
				<br>
				<div class="form-group">
					<label class="col-lg-3 control-label" for="textarea">Isi</label>
					<div class="col-lg-6">
						<textarea class="form-control elastic" rows="4" name="isi"><?=$set_isi?></textarea>						
					</div>
					<font color="red"><?php echo form_error("nama"); ?></font>
				</div>
				<br>
				<br>
				<br>
				<br>
				<br>
				<div class="form-group">
					<label class="col-lg-3 control-label" for="select">Media</label>
					<div class="col-lg-6">
						<?php if(!isset($id)){?>
						<?php 
							$js = ' id="media" class="nostyle form-control" ' ;
							echo form_dropdown("media",$media,"",$js);
						?>
						<?php }else{?>
						<?php
							$js = ' id="media" class="nostyle form-control" ' ;
							echo form_dropdown("media",$media,$set_media,$js);
						?>
						<?php }?>						
					</div>
					<font color="red"><?php echo form_error("nama"); ?></font>
				</div>
				<br>
				<br>
				<div class="form-group">
					<label class="col-lg-3 control-label" for="date">Tanggal</label>
					<div class="col-lg-6">
						<?php if(!isset($id)){?>
							<input type="text" id="tanggal" name="tanggal" class="form-control elastic"  value="<?php echo date('d-m-Y')?>">
						<?php }else{?>
							<input type="text" id="tanggal" name="tanggal" class="form-control elastic"  value="<?php echo date('d-m-Y', strtotime($set_tanggal))?>">
						<?php }?>						
					</div>
					<font color="red"><?php echo form_error("tanggal"); ?></font>
				</div>
				<br>
				<br>
				<?php if(!isset($id)){ echo "
				<div class='form-group'>
					<label class='col-lg-3 control-label' for='radio'>Jenis Masukan</label>
					<div class='col-lg-6'>
						<label class='radio-inline'>
							<input name='jenis_masukan' type='radio' id='inlineCheckbox1' value='1' onClick='j_pengaduanb'> Pengaduan
						</label>
						<label class='radio-inline'>
							<input name='jenis_masukan' type='radio' id='inlineCheckbox1' value='2' onClick='j_saranb'> Saran
						</label>
					</div>
				</div>
				<br>
				<br>
				";
				}else{
					if(!isset($id_saran)){
					echo "<input type='text' value='1' name='jenis_masukan' style='display:none;'>";
					}else{
					echo "<input type='text' value='2' name='jenis_masukan' style='display:none;'>";
					}
				}
				?>
				<div class="form-group" id="j_pengaduan">
					<label class="col-lg-3 control-label" for=""></label>
					<div class="col-lg-6">
						<select name="j_pengaduan">
							<option value="1">keterlambatan SK/retribusi</option>
							<option value="2">petugas</option>
							<option value="3">sarana prasarana</option>
							<option value="4">lingkungan kerja</option>
							<option value="5">mekanisme prosedur</option>
						</select>			
					</div>
					<br>
					<br>
				</div>
				<div class="form-group" id="j_saran">
					<label class="col-lg-3 control-label" for=""></label>
					<div class="col-lg-6">
						<select name="j_pengaduan">
							<option value="1">keterlambatan SK/retribusi</option>
							<option value="2">petugas</option>
							<option value="3">sarana prasarana</option>
							<option value="4">lingkungan kerja</option>
							<option value="5">mekanisme prosedur</option>
						</select>			
					</div>
					<br>
					<br>
				</div>
				<div class="form-group">
					<label class="col-lg-3 control-label" for="radio">Terkait Ijin ?</label>
					<div class="col-lg-6">
						<?php if(!isset($id)) { ?>
							<label class="radio-inline">
								<input name="terkait_ijin" type="radio" id="inlineCheckbox1" value="1" onClick="show()"> Ya
							</label>
							<label class="radio-inline">
								<input name="terkait_ijin" type="radio" id="inlineCheckbox1" value="2" onClick="hide()"> Tidak
							</label>
						<?php }else{ ?>
							<label class="radio-inline">
								<input name="terkait_ijin" type="radio" id="inlineCheckbox1" value="1" 
									<?php echo set_value('radio', $set_ijin) != NULL ? "checked" : ""; ?>
								onClick="show()"> Ya
							</label>
							<label class="radio-inline">
								<input name="terkait_ijin" type="radio" id="inlineCheckbox1" value="2" 
									<?php echo set_value('radio', $set_ijin) == NULL ? "checked" : ""; ?>
								onClick="hide()"> Tidak
							</label>
						<?php }?>
					</div>
				</div>
				<br>
				<div id="advanced_ijin">
					<div class="form-group">
						<label class="col-lg-3 control-label" for="select">Ijin</label>
						<div class="col-lg-6">
							<select class="nostyle form-control" id="ijin" name="ijin">
								<?php 
									echo '<option value="">--- Pilih Jenis Ijin ---</option>';
									foreach($dropdown_ijin as $row)
										{ 
											echo '<option value="'.$row["ID_IJIN"].'">'.$row["NAMA_IJIN"].'</option>';
										}
								?>
							</select>
						</div>
					</div>
					<br>
					<br>
					<br>
					<div class="form-group">
						<label class="col-lg-3 control-label" for="input">No. UPTSA</label>
						<div class="col-lg-6">
							<input class="form-control" id="no_uptsa" name="no_uptsa" type="text" value="<?=$set_uptsa?>"/>
						</div>
					</div>
				</div>
				<br>
				<br>
				<div class="form-group">
					<div class="col-lg-offset-3 col-lg-9">
						<button type="submit" class="btn btn-info">Simpan</button>&nbsp;&nbsp;
						<button type="reset" class="btn btn-warning">Reset</button>&nbsp;&nbsp;
						<?php if(isset($id)){ 
							if(!isset($id_saran)){
								echo "<button type='button' class='btn btn-default' onClick='kembali()'>Kembali</button>";
							}else{
								echo "<button type='button' class='btn btn-default' onClick='kembali2()'>Kembali</button>";
							}
						}
						?>
					</div>
				</div>
			</div>
			<?php echo form_close();?>
		</div>
	</div>
</div>
<script>
var cek_radio_ijin = "<?=$set_uptsa?>";
function show(){
	$("#advanced_ijin").show("slow");
}
function hide(){
	$("#advanced_ijin").hide("slow");
}
function kembali(){
	document.location = "<?php echo site_url('pengaduan_saran/grid_list_pengaduan');?>";
}
function kembali2(){
	document.location = "<?php echo site_url('pengaduan_saran/grid_list_saran');?>";
}
function j_pengaduanb(){
	$("#j_pengaduan").show("slow");
	$("#j_saran").hide("slow");
}
function j_saranb(){
	$("#j_saran").show("slow");
	$("#j_pengaduan").hide("slow");
	
}
$(document).ready(function (){

	if(cek_radio_ijin != ''){
		$("#advanced_ijin").show();
	}else{
		$("#advanced_ijin").hide();
	}
	
	$("#j_pengaduan").hide();
	$("#j_saran").hide();
	
	if($('#tanggal').length) {
		$('#tanggal').datepicker({
	        inline: true,
			dateFormat:"dd-mm-yy",
			showOtherMonths:true
	    });
	}
	$("#no_telp").keydown(function (e) {
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
            (e.keyCode == 65 && e.ctrlKey === true) || 
            (e.keyCode >= 35 && e.keyCode <= 39)) {
                 return;
        }
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    });
});
</script>